import { request } from '@/utils/request';

import type { PageData } from '@/api/model/pageModel';
import type {
  GenerateHumanAnimeStyleResponseBodyData,
  TranslateImageBatchResult,
  Txt2ImgRequest,Txt2ImgResponse,AiImageQueryRequest,AiImageQueryResponse,
  AiImgInfo,
  ImgPkMatchModel,
  TxtWatermarkAddModel,PicWatermarkAddModel,watermarkResolveModel,TxtWatermarkResult,PicWatermarkResult
} from '@/api/model/pictureModel';

const Api = {
  GenerateHumanAnimeStyle: '/image/GenerateHumanAnimeStyle',
  BatchTranslateImage: '/imgtranslate/batch', //批量图片翻译
  QueryTranslateImage: '/imgtranslate/query',
  RandomText:'/image/randomtxt', //随机文字
  Text2Image:'/image/txt2img', //文字生图
  AiImgQuery:'/image/result', //AI图片查询
  MyAiImgList:'/image/list',
  DelAiImg:'/image/del',
  PkCreate:'/image/match', //ai绘画大赛
  WatermarkTxtAdd:'/image/watermark/txt',
  WatermarkPicAdd:'/image/watermark/pic',
  WatermarkResolve:'/image/watermark/resolve'

};

//人物动漫化
export function generateHumanAnimeStyle(d: any) {
  return request.post<GenerateHumanAnimeStyleResponseBodyData[]>({
    url: Api.GenerateHumanAnimeStyle,
    data: d,
  });
}

//图片批量翻译
export function translateImage(d: any) {
  return request.post<string>({
    url: Api.BatchTranslateImage,
    data: d,
  });
}
//图片批量翻译查询
export function getTranslateImage(taskId: string) {
  return request.get<TranslateImageBatchResult[]>({
    url: Api.QueryTranslateImage + '?taskId=' + taskId,
  });
}

//获取随机AI文字
export function getRandomText() {
  return request.get<TranslateImageBatchResult[]>({
    url: Api.RandomText ,
  });
}
//文本生成图片
export function txt2Img(d:Txt2ImgRequest){
  return request.post<Txt2ImgResponse>({
    url: Api.Text2Image,
    data: d,
  });
}
//查询ai图片结果
export function queryAiImg(d:AiImageQueryRequest){
  return request.post<AiImageQueryResponse>({
    url: Api.AiImgQuery ,
    data:d
  });
}
// {"row":{"id":208,"apiProvider":"baidu-txt2img","apiName":"AI画图","request":"{\"text\":\"AI绘画大赛\",\"resolution\":\"1024*1024\",\"style\":null,\"num\":1}","response":"{\"data\":null,\"log_id\":1687105435109802084,\"error_code\":282004,\"error_msg\":\"输入的query检测不通过\",\"error\":null,\"error_description\":null}","jobId":"1687101069759732174","jobResult":"","jobStatus":1,"createDate":"2023-08-03 22:00:15","userId":"9215508b6c164307ba0a7985450da24b","groupId":""},"col":{"align":"left","fixed":"right","width":130,"colKey":"op","title":"操作"},"rowIndex":0,"colIndex":5}

//查用户AI作品
export function pageMyAiImage(d:any){
  return request.get<PageData<AiImgInfo>>({
    url: Api.MyAiImgList+"?page="+d.page+"&pagesize="+d.pageSize ,
    data:d
  });
}
//删除用户作品
export function deleteAiImage(id:any){
  return request.delete<object>({
    url:Api.DelAiImg+'?id='+id
  });
}

//AI绘图大赛-创建
export function pk(imgId:number){
  return request.post<ImgPkMatchModel>({
    url:Api.PkCreate,
    data:{
      AiImgId:imgId
    }
  })
}

//添加文字水印
export function addTxtWatermark(d:TxtWatermarkAddModel){
  return request.post<Array<TxtWatermarkResult>>({
    url:Api.WatermarkTxtAdd,
    data:d
  })
}
//添加图片水印
export function addPicWatermark(d:PicWatermarkAddModel){
  return request.post<Array<PicWatermarkResult>>({
    url:Api.WatermarkPicAdd,
    data:d
  })
}
//解析文字水印
export function resolveTxtWatermark(d:watermarkResolveModel){
  return request.post<Array<TxtWatermarkResult>>({
    url:Api.WatermarkResolve,
    data:d
  })
}
//解析图片水印
export function resolvePicWatermark(d:watermarkResolveModel){
  return request.post<Array<PicWatermarkResult>>({
    url:Api.WatermarkResolve,
    data:d
  })
}

